require 'pp'
require 'softlayer/object_storage'
require 'softlayer/object_storage/version'
require 'softlayer/object_storage/connection'
require 'softlayer/object_storage/authentication'
require 'softlayer/object_storage/exception'
require 'softlayer/object_storage/container'
require 'softlayer/object_storage/storage_object'

# ObjectStorage Wrapper class
class OSWrapper
	
	def initialize(uname, apikey, datacenter)
		@slObjectStorage = SoftLayer::ObjectStorage::Connection.new({
	    	:username => uname,
	    	:api_key => apikey,
	    	:datacenter => datacenter
		})
	end
	
	def environmentExist(envName)
		envExist = false
		@slObjectStorage.containers.each do |cont|
			envExist = cont == envName
			if envExist == true then
				break
			end
		end
		return envExist
	end 
	
	def createEnvironment(envName, outputconfig)
		@slObjectStorage.create_container(envName)
		container = @@slObjectStorage.container(envName)
		objectName = "#{envName}.yml"
		container.create_object(objectName).write(outputconfig.to_yaml())
	end
end